import React, { Component } from 'react'
import {
    View,
    Text,
    Image,
    TouchableOpacity,                     //底部刷新小组件
} from 'react-native';

import { M_position_content_1 as styles } from '../../../../styles'     //引入样式完毕
import fmt from '../../../util/fmtDateUtil';
import sal from '../../../util/sal';
import {common_url} from "../../../util/fetch";

var Dimensions = require('Dimensions');
var width = Dimensions.get('window').width;
var height = Dimensions.get('window').height;

export default class Zuixin extends Component {
    constructor(props) {
        super(props);
    }
    render() {
        return (
            <TouchableOpacity
                activeOpacity={1}//透明度
                onPress={() => { this.goGet('Postionin', this.props.postion.postionId); }}
            >
                <View style={styles.container}>
                    <View style={styles.title}>
                        <Text style={styles.titleColor_1}>{this.props.postion.postionName}</Text>
                        <Text style={styles.titleColor_2}>{sal(this.props.postion.postionMm, this.props.postion.postionYm)}</Text>
                    </View>
                    <View style={styles.intro}>
                        <View style={styles.introLeft}>
                            <Text style={[styles.introLeft_Text, { paddingLeft: 0 }]}>{this.props.postion.postionSpace}</Text>
                            <Text style={styles.introLeft_Text}>{this.props.postion.postionExp}年经验</Text>
                            <Text style={[styles.introLeft_Text, { borderRightWidth: 0 }]}>{this.props.postion.postionEducation}</Text>
                        </View>
                        <Text style={styles.introRight_Text}>{fmt(this.props.postion.postionTime, "yyyy-MM-dd")}</Text>
                    </View>
                    <View style={styles.introPostion}>
                        <Image source={
                            this.props.company.companyPicture ?
                                {uri: common_url + "uploadImg/" + this.props.company.companyPicture}
                                : require('../../../img/app/company.png')} style={styles.Img} />
                        <View style={styles.introPostion_right}>
                            <Text style={styles.introPostion_Text}>{this.props.company.companyName}</Text>
                            <Text style={styles.introPostion_Text}>{this.fieldName(this.props.domains, 3)}</Text>
                        </View>
                    </View>
                </View>
            </TouchableOpacity>
        )
    }

    //经营领域
    fieldName(List, sl) {
        var data = {
            cont: List
        }
        var arr = '';                            //用来装公司类型
        var s = sl;
        var length = data.cont.length
        if (length <= s) {
            s = length
        }
        for (var i = 0; i < s; i++) {
            arr += data.cont[i].field.fieldName + '/';
        }
        if (arr.endsWith('/')) {
            arr = arr.substr(0, arr.length - 1);
        }
        return arr;
    }

    goGet(name, id) {
        this.props.navigation.navigate(name, { useId: id });
    }
}